package net.ocps.htc.SpeedReactor.screens;

import net.ocps.htc.SpeedReactor.Input;
import net.ocps.htc.SpeedReactor.SpeedReactor;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Matrix4;

public abstract class Screen {

	public SpriteBatch spriteBatch;
	public SpeedReactor speedReactor;
	
	public void removed() {
		spriteBatch.dispose();
	}
	
	public void init(SpeedReactor speedReactor) {
		this.speedReactor = speedReactor;
		Matrix4 projection = new Matrix4();
		projection.setToOrtho(0, 1280, 720, 0, -1, 1);
		
		spriteBatch = new SpriteBatch();
		spriteBatch.setProjectionMatrix(projection);
	}
	
	public void setScreen(Screen screen) {
		speedReactor.setScreen(screen);
	}
	
	public void draw (TextureRegion region, int x, int y) {
		int width = region.getRegionWidth();
		if (width < 0) width = -width;
		spriteBatch.draw(region, x, y, width, region.getRegionHeight());
	}

	public abstract void render();
	
	public void tick (Input input) {
	}
}
